<?php



include 'utilities.php';
include 'crawl.php';
Utititles::includeClasses();

$crawl = new Crawl();
$tb_games = new Tb_Games();
$games = $tb_games->getUrlBankers();
$banners = array();

$pattern = '/<div.*?class="one-zone-log">[\n\s\t\r]*<div.*?class="log-time">(.*?)<\/div>[\n\s\t\r]*<div.*?class="log-value">[\n\s\t\r]*<p.*?class="name-team">(.*?)<\/p>[\n\s\t\r]*<p.*?class="name-team">(.*?)<\/p>[\n\s\t\r]*/';

/*
<div.*?class="one-zone-log">[\n\s\t\r]*
<div.*?class="log-time">(.*?)<\/div>[\n\s\t\r]*
<div.*?class="log-value">[\n\s\t\r]*
<p.*?class="name-team">(.*?)<\/p>[\n\s\t\r]*
<p.*?class="name-team">(.*?)<\/p>[\n\s\t\r]*
 */
/*
 * $matches
 * [1]-Date/Start
 * [2]-Ou/O
 * [3]-u/u
 */
$IB = 0;
if (count($games) > 0) {
    foreach ($games as $game) {

        //Asian


        //Ou
        $url = $game['url_ou'];
        $url = "http://ibongda.vn/keo-bong-da/tai-xiu/cesena-vs-padova-u192570.rt";
        $data = $crawl->getPage($url);
        $matches = $crawl->parseData($data, $pattern);

        if (!empty($matches[1][0])) {
            for ($i = 0; $i < count($matches[1]); $i++) {
                if (temp::isValidDateVN($matches[1][$i])) {
                    $banners['ou'][] = $matches[1][$i];
                    
                } else {
                    
                }
            }
        }
        //Europe
        $game = '';
    }
}

class temp {
    public static function isValidDateVN($date) {
        return (preg_match("/^([0-9]{2})\/([0-9]{2})\/([0-9]{4})/", $date));
    }
}